/**
 * copyright 2007, hi5 networks 
 *
 * @fileoverview hi5 representation of the person interface.
 */

goog.provide('people.Hi5Person');

/**
 * Create a person.
 *
 * @param {String} id The id of the person
 * @param {String} name The name of the person
 * @param {String} pictureUrl The url of the person's photo
 * @param {Array<String>} installedApps An array of strings representing which
 *     apps are installed
 * @param {Map<String, String>} appData A map from app fields to app values
 * @param {Boolean} isViewerObject If true, this person is the currently logged
 *   in user.
 * @constructor
 */
opensocial.Hi5Person = function(id, opt_fields, opt_isViewer, opt_isOwner) {
  this.fields = opt_fields || {};
  this.fields[opensocial.Person.Field.ID] = id;
  this.isViewer = opt_isViewer || false;
  this.isOwner = opt_isOwner || false;
};

opensocial.Hi5Person.prototype.getId = function() {
  return this.fields[opensocial.Person.Field.ID];
};


/**
 * If the name field is set, then return it. If not try to do
 * something meaningful using the email address.
 */
opensocial.Hi5Person.prototype.getDisplayName = function() {
  var name = this.fields[opensocial.Person.Field.NAME];
  if (name) {
    return name;
  } 
  return '';
};


opensocial.Hi5Person.prototype.getField = function(key) {
  if (key == opensocial.Person.Field.PROFILE_URL) {
      return "http://www.hi5.com/friend/profile/displayProfile.do?userid=" + this.getId();
  }
  return this.fields[key];
};


opensocial.Hi5Person.prototype.isViewer = function() {
  return this.isViewer;
};


opensocial.Hi5Person.prototype.isOwner = function() {
  return this.isOwner;
};
